<%= content_for :page_meta do %>
  <% title_with_timeframe(
       page_title: community_name,
       timeframe: params[:timeframe],
       content_for: true,
     ) %>

  <link rel="canonical" href="<%= app_url(request.path) %>" />
  <meta name="description" content="<%= Settings::Community.community_description %>">
  <%= meta_keywords_default %>

  <meta property="og:type" content="website" />
  <meta property="og:url" content="<%= app_url(request.path) %>" />
  <meta property="og:title" content="<%= title_with_timeframe(page_title: community_name, timeframe: params[:timeframe]) %>" />
  <meta property="og:image" content="<%= Settings::General.main_social_image %>">
  <meta property="og:description" content="<%= Settings::Community.community_description %>" />
  <meta property="og:site_name" content="<%= community_name %>" />

  <meta name="twitter:site" content="@<%= Settings::General.social_media_handles["twitter"] %>">
  <meta name="twitter:title" content="<%= title_with_timeframe(page_title: community_name, timeframe: params[:timeframe]) %>">
  <meta name="twitter:description" content="<%= Settings::Community.community_description %>">
  <meta name="twitter:image:src" content="<%= Settings::General.main_social_image %>">
  <meta name="twitter:card" content="summary_large_image">
  <%= auto_discovery_link_tag(:rss, app_url("feed"), title: t("views.stories.meta.rss", name: community_name)) %>
<% end %>

<%= javascript_include_tag "homePage", defer: true %>
<% cache(release_adjusted_cache_key("main-stories-index-#{params}-#{user_signed_in?}"), expires_in: 90.seconds) do %>
  <% if @hero_billboard && FeatureFlag.enabled?(:hero_billboard) %>
    <%= render partial: "shared/billboard", locals: { billboard: @hero_billboard, data_context_type: BillboardEvent::CONTEXT_TYPE_HOME } %>
  <% end %>
  <div class="crayons-layout crayons-layout--3-cols crayons-layout--3-cols--drop-right-left" id="index-container"
      data-params="<%= params.merge(sort_by: "hotness_score", sort_direction: "desc").to_json(only: %i[tag username q sort_by sort_direction]) %>" data-which="<%= @list_of %>"
      data-tag=""
      data-feed="<%= params[:timeframe] || "base-feed" %>"
      data-feed-use-stories-endpoint="<%= user_signed_in? && FeatureFlag.enabled?(:use_stories_endpoint) %>"
      data-feed-context-type="<%= FeedEvent::CONTEXT_TYPE_HOME %>"
      <% FeedEvent.categories.keys.each do |category| %>
      data-feed-category-<%= category %>="<%= category %>"
      <% end %>
      data-articles-since="<%= Timeframe.datetime_iso8601(params[:timeframe]) %>">

    <%= render "articles/sidebar" %>

    <%# BEGIN Feed menu bar %>
    <main class="articles-list crayons-layout__content" id="main-content" data-follow-button-container="true">
      <% if user_signed_in? && !ArticlePolicy.is_root_subforem? %>
        <%= application_policy_content_tag("div", record: Article, query: :create?) do %>
          <%= render "articles/quickie_form", expanded: false %>
        <% end %>
      <% end %>
      <%= render(partial: "onboardings/task_card") if user_signed_in? %>

      <header class="p-2 px-3 m:p-0 m:px-0 m:mb-2 fs-l">
        <h1 class="screen-reader-only"><%= t("views.stories.heading") %></h1>
        <%= render "articles/feed_nav" %>
      </header>

      <% if user_signed_in? %>
        <div id="homepage-feed" style="min-height: 90vh"></div>
      <% else %>
        <%= render "stories/main_stories_feed" %>
      <% end %>

      <div id="followed-podcasts" data-episodes="<%= @podcast_episodes.to_json(include: { podcast: { only: %i[slug title id], methods: %i[image_90] } }) %>"></div>
      <div class="loading-articles" id="loading-articles">
        <%= t("core.loading") %>
      </div>
    </main>

    <%= render "articles/sidebar_additional" %>
  </div>

  <%= javascript_include_tag "storiesList", "feedPreviewCards", "heroBannerClose", "localizeArticleDates", "feedEvents", "sidebar-sticky", defer: true %>
<% end %>
